/*
 * $Id: SizeParams.java 23 2011-05-20 14:46:26Z rob.whelan@patientsknowbest.com $ 
 */
package com.representqueens.spark;

/*
 * 
 * Copyright 2006 Larry Ogrodnek
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Graph size attributes.
 * 
 * @author Larry Ogrodnek <larry@cheesesteak.net>
 * @version $Revision: 23 $ $Date: 2011-05-20 14:46:26 +0000 (Fri, 20 May 2011) $
 */
public final class SizeParams {
	public final static int PADDING = 3;
	private final int imgWidth, imgHeight;
    private final int spacing;
    private final Double forceYMin, forceYMax;
    private final Double forceXMin, forceXMax;

    /**
     * Constructor.
     * 
     * @param width
     *            graph width (in pixels).
     * @param height
     *            graph height (in pixels).
     * @param spacing
     *            spacing between data points (in pixels).
     */
    public SizeParams(final int width, final int height, final int spacing) {
	this(width, height, spacing, null, null, null, null);
    }

    /**
     * Constructor
     * 
     * @param width
     *            graph width (in pixels)
     * @param height
     *            graph height (in pixels)
     * @param spacing
     *            spacing between data points (in pixels)
     * @param forceYMin
     *            if non-null, the minimum to use on the chart. For example,
     *            passing in 0 will force the line to appear as if there were
     *            data points at 0, even if there aren't. If this value is
     *            non-null, and forceMax is null, max will be discovered from
     *            the dataset.
     * @param forceYMax
     *            if non-null, the maximum to use on the chart. For example,
     *            passing in 100 will force the line to appear as if there were
     *            data points at 100, even if there aren't. If this value is
     *            non-null, and forceMin is null, min will be discovered from
     *            the dataset.
     */
    public SizeParams(int imgWidth, int imgHeight, int spacing, Double forceYMin,
	    Double forceYMax, Double forceXMin, Double forceXMax) {
	this.imgWidth = imgWidth;
	this.imgHeight = imgHeight;
	this.spacing = spacing;
	this.forceYMin = forceYMin;
	this.forceYMax = forceYMax;
	this.forceXMin = forceXMin;
	this.forceXMax = forceXMax;
    }


    public int getImgWidth() {
		return imgWidth;
	}

	public int getImgHeight() {
		return imgHeight;
	}
	
    /**
     * Get the graph height.
     * 
     * @return graph height (in pixels).
     */
    public int getHeight() {
	return this.imgHeight - PADDING*2;
    }

	/**
     * Get the spacing between data points.
     * 
     * @return spacing between data points (in pixels).
     */
    public int getSpacing() {
    	return this.spacing;
    }

    /**
     * Get the graph width.
     * 
     * @return graph width (in pixels).
     */
    public int getWidth() {
    	return this.imgWidth - PADDING*2;
    }

    /**
     * The max to use on the chart. If null, the max is discovered automatically
     * based on the dataset.
     * 
     * @return forced y max (in context of the dataset), or null
     */
    public Double getForceYMax() {
    	return forceYMax;
    }

    /**
     * The min to use on the chart. If null, the min is discovered automatically
     * based on the dataset.
     * 
     * @return forced y min (in context of the dataset), or null
     */
    public Double getForceYMin() {
	return forceYMin;
    }

    /**
     * The min to use on the chart. If null, the min is discovered automatically
     * based on the dataset.
     * 
     * @return forced x min (in context of the dataset), or null
     */
	public Double getForceXMin() {
		return forceXMin;
	}

    /**
     * The max to use on the chart. If null, the max is discovered automatically
     * based on the dataset.
     * 
     * @return forced x max (in context of the dataset), or null
     */
	public Double getForceXMax() {
		return forceXMax;
	}
}
